package april.example.channel_group;

import java.net.InetSocketAddress;
import java.util.concurrent.Executors;

import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;

public class Client {

	private String host;
	private int port;

	public Client(String host, int port) {
		this.host = host;
		this.port = port;
	}

	public void run() {
		ClientBootstrap bootstrap = new ClientBootstrap(
				new NioClientSocketChannelFactory(
						Executors.newCachedThreadPool(),
						Executors.newCachedThreadPool()));

		bootstrap.setPipelineFactory(new ClientPipelineFactory());
		ChannelFuture future = bootstrap.connect(new InetSocketAddress(host,
				port));
		
		future.getChannel().getCloseFuture().awaitUninterruptibly();
	}

	public static void main(String[] args) {
		new Client("172.16.101.19", 20134).run();
	}

}
